package com.omenkk.juc.c1;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class demo4 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            while(true){
                if(Thread.currentThread().isInterrupted()){
                    //如果当前状态中断状态为true
                    break;
                }
            }
            log.debug("t1结束");
        },"t1");
        //设置为守护线程,当main线程结束了，即使t1线程代码没执行完，也会强制结束
        t1.setDaemon(true);
        t1.start();


        Thread.sleep(1000);
        log.debug("main线程结束");
    }
}
